package com.micookie.v2ex.ui.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/27.
 */

public class ViewPagerAdapter extends PagerAdapter {
    ArrayList<View> viewList;
    ArrayList<String> tabList;


    public ViewPagerAdapter(ArrayList<View> viewList, ArrayList<String> tabList) {
        this.viewList = viewList;
        this.tabList = tabList;
    }


    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position));
        return viewList.get(position);
    }


    @Override
    public int getCount() {
        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }
}
